package com.stars.empoly.activity

import androidx.fragment.app.Fragment
import com.qmuiteam.qmui.widget.tab.QMUITab
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder
import com.stars.empoly.base.MBTabActivity
import com.stars.empoly.databinding.ActivityDriverOrderBinding
import com.stars.empoly.fragment.DriverOrderListFragment
import com.stars.empoly.vmodel.DriverOrderVModel
import com.trailer.base.utils.B

/**
 * 司机端-订单
 *on 2021/5/14
 */
class DriverOrderActivity : MBTabActivity<DriverOrderVModel, ActivityDriverOrderBinding>() {


    override fun vmClass(): Class<DriverOrderVModel> {
        return DriverOrderVModel::class.java
    }

    override fun createTabs(tabBuilder: QMUITabBuilder): Array<QMUITab> {
        val component = tabBuilder
                .setText("全部")
                .build(context())
        val util = tabBuilder
                .setText("进行中")
                .build(context())

        val complete = tabBuilder
                .setText("已完成")
                .build(context())

        return arrayOf(component, util, complete)
    }

    override fun binding(): ActivityDriverOrderBinding {
        return ActivityDriverOrderBinding.inflate(layoutInflater)
    }

    override fun getPageItem(position: Int): Fragment {

        var ownerFragment = DriverOrderListFragment()
        when (position) {
            0 -> {
                ownerFragment.arguments = B().putString("order_state", "0").ok()
                return ownerFragment
            }

            1 -> {
                ownerFragment.arguments = B().putString("order_state", "1").ok()
                return ownerFragment

            }
            2 -> {
                ownerFragment.arguments = B().putString("order_state", "2").ok()
                return ownerFragment

            }

            else -> {
                ownerFragment.arguments = B().putString("order_state", "0").ok()
                return ownerFragment
            }

        }

    }

    override fun getPageCount(): Int {
        return 4
    }

    override fun title(): String? {
        return "我的订单"
    }
}
